Skip to content

Per key/layer RGB underglow for 25.11#36

Open
darknao wants to merge 18 commits into
moergo-sc:zmk-updatefrom
darknao:rgb-layer-24.12
Open

Per key/layer RGB underglow for 25.11#36
darknao wants to merge 18 commits into
moergo-sc:zmk-updatefrom
darknao:rgb-layer-24.12

Conversation

@darknao

@darknao darknao commented Dec 30, 2024

Copy link
Copy Markdown

This adds per key / per layer RGB underglow configuration on top of 25.11.
It's mainly based on @valdur mod with additional changes to make it configurable via devicetree.

This supersedes #30.

It includes:

  • Valdur's RGB mod
  • Refactor, move configuration to devicetree, and some battery life optimization
  • feat(split): Increase split interval during idle #682 from ZMK upstream

How to use:
Full example on the Layout Editor here

To preserve battery life, I recommend enabling the ZMK_RGB_UNDERGLOW_AUTO_OFF_IDLE KConfig to automatically turn off underglow after ZMK_IDLE_TIMEOUT ms (default to 30 seconds).
From my limited experience, you can expect around one week of battery life with no RGB on the base layer.

Upstream PR: zmkfirmware#2752

@helto4real

Copy link
Copy Markdown

Thanks for your work on this. I tried your PR and everything seem to work with the Glorious Engrammer v40. I enjoy finally being able to set RGB values individually.

@gillamkid

Copy link
Copy Markdown

I tested using the Glove80 Layout Editor and was it worked for me! My layout can be seen here: https://dev.glove80.com/#/layout/user/6de3c382-9ced-4de8-a1a4-368b26e09d3f

Is this a feature that will make it into ZMK or Glove80 main or will it will it likely stay as a PR?

@darknao

darknao commented Jan 4, 2025

Copy link
Copy Markdown
Author

Is this a feature that will make it into ZMK or Glove80 main or will it will it likely stay as a PR?

My plan is to open a similar PR on ZMK, and see if I can work on getting it merged.
There are a few things that I need to clean up first, such as glove80-specific pieces of code, but I think I'm almost done with that.

@darknao

darknao commented Jan 4, 2025

Copy link
Copy Markdown
Author

The latest update introduces some breaking changes:

  • New format for the RGB binding: Underglow color is now set with &ug COLOR instead of just COLOR. This allows some advanced functionalities by using behavior, just like for keymap.
  • You can set underglow colors based on HID indicators such as NumLock, CapsLock & ScrollLock with the following behaviors:
    • &ug_nl COLOR_OFF COLOR_ON set the RGB according to the NumLock state.
    • &ug_cl COLOR_OFF COLOR_ON is for CapsLock.
    • &ug_sl COLOR_OFF COLOR_ON is for ScrollLock.
  • The HID indicators require the CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS Kconfig set. Without it, only the left side can use them. (That Kconfig is now set by default)
  • The old ______ (RGB off, 5 underscores) was renamed to ___ (3 underscores).

@gillamkid

gillamkid commented Jan 7, 2025

Copy link
Copy Markdown

I used the latest pr36 rgb 20250106120812 version on the Glove80 Layout Editor today (with the new &ug way of doing things) and it worked for me!

This is my Layout: https://dev.glove80.com/#/layout/user/c458ddd6-cac3-4269-a578-a1d9cd506e94

@dbosky

dbosky commented Jan 10, 2025

Copy link
Copy Markdown

Did anybody try to enable HID_POINTING and EXPERIMENTAL_RGB_LAYER on Engrammer v40 with this FW? RGB works for me but for some reason mouse is not. I did factory reset.

@darknao darknao changed the base branch from zmk-update to main January 25, 2025 14:39
@darknao darknao changed the title Per key/layer RGB underglow for 24.12 Per key/layer RGB underglow for 25.01 Jan 25, 2025
@darvelo

darvelo commented Feb 2, 2025

Copy link
Copy Markdown

@darknao First of all thank you so much for this work. It makes knowing which layer I'm on with a single LED possible, which is crucial for my photoshop and blender work. I use no LEDs for the base layer and just one LED at half brightness for other layers.

For some reason this PR seems to result in faster battery drain than #30 with the same sleep and deep sleep settings that I had for #30, not sure why. Also there are some bugs like the light turning off and not coming back, or the magic layer lights turning on at random, that #30 didn't have. Maybe it's just me? Or maybe it's something in the firmware bump to 25.01?

@darknao

darknao commented Feb 2, 2025

Copy link
Copy Markdown
Author

I think it would be a good idea to ask on the MoErgo discord. It is much easier for me to track down those issues over there, and you can ask if anyone else has the same bugs.

The changes in this PR are pretty much the same as for #30, but they are based on an updated version of ZMK. It is possible that upstream changes affected battery life. So far, I haven't noticed a big change on my side: I was close to 17 days with PR30, and I think I'm very close to that with this PR.
I didn't notice any light turning off or the magic layer turning on at random, so not sure what could have caused that.

If you build your firmware with my.glove80.com, you might be interested in testing a new version of this firmware on dev.glove80.com. The one currently on dev fixes a few bugs including when using sleep mode.

@darvelo

darvelo commented Feb 2, 2025

Copy link
Copy Markdown

@darknao All right, thank you. It's possible some of the light stuff is user error and my keyboard is tucked under my tablet and tapping the toggle base layer switch without me noticing. I may have also just flashed it incorrectly so I'll try again.

# Copyright (c) 2024, The ZMK Contributors
# SPDX-License-Identifier: MIT

description: Set underglow for num lock indicator

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inaccurate description. This file is more general and also used for the scroll-lock indicator and capslock indicator


#include <dt-bindings/zmk/hid_indicators.h>

/ {

@gillamkid gillamkid Feb 5, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this PR, I use it for every build :)

I would love it if there was also a behavior that makes so color is changed for the specified key if ctrl, shift, or alt is pressed

would also be great if I could make a key change color if the key itself is pressed

@darvelo

darvelo commented Feb 5, 2025

Copy link
Copy Markdown

Just for posterity, I think my battery drain and some other issues were just due to constant use of the keyboard while using Photoshop. I think this PR is great and very useful and helpful 👍🏽

@raylau1234

Copy link
Copy Markdown

The latest update introduces some breaking changes:
...

  • &ug_cl COLOR_OFF COLOR_ON is for CapsLock.

This is super! Would be great if we can indicate CapsWord mode as well.

@Greg-Bm

Greg-Bm commented Feb 25, 2025

Copy link
Copy Markdown

I found an issue where toggling rgb patterns throught the per key rgb layer can temporarily disable rgb on the right half. how to replicate:

  1. use glorious engrammer firmware (I had per key rgb enabled, mouse keys enabled and BLE_CTLR_PHY_2M explicitly set to 'n')
  2. enable rgb
  3. cycle rgb mode to the per-key rgb layer
  4. change rgb mode again. now the left half, but not the right half, should be lit.
IMG_4406.MOV

@darknao darknao changed the base branch from main to zmk-update April 13, 2025 17:19
@darknao darknao changed the title Per key/layer RGB underglow for 25.01 Per key/layer RGB underglow for 25.04 Apr 13, 2025
@ror3d

ror3d commented Apr 19, 2025

Copy link
Copy Markdown

I was trying this out but it doesn't seem to work for me
Actually I realized the issue, it is that you have to change the the proper underglow preset for it to activate, I was expecting it to work on top of the one I had selected which was solid colour.

@petergaultney

Copy link
Copy Markdown

I've been testing/using this for ~5 months and it's been great. I'd love to see this get integrated with the main branch.

@darknao darknao changed the title Per key/layer RGB underglow for 25.04 Per key/layer RGB underglow for 25.08 Aug 4, 2025
Comment thread app/boards/arm/glove80/glove80_rh.dts Outdated
Comment on lines +25 to +27
pixel-lookup = <57>, <56>, <55>, <74>, <73>, <72>, <16>, <28>, <40>, <58>, <5>, <17>, <29>, <41>,
<59>, <75>, <6>, <18>, <30>, <42>, <60>, <76>, <7>, <19>, <31>, <43>, <61>, <77>,
<8>, <20>, <32>, <44>, <62>, <78>, <9>, <21>, <33>, <45>, <63>, <79>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pixel-lookup = <57>, <56>, <55>, <74>, <73>, <72>, <16>, <28>, <40>, <58>, <5>, <17>, <29>, <41>,
<59>, <75>, <6>, <18>, <30>, <42>, <60>, <76>, <7>, <19>, <31>, <43>, <61>, <77>,
<8>, <20>, <32>, <44>, <62>, <78>, <9>, <21>, <33>, <45>, <63>, <79>;
pixel-lookup = <57>, <56>, <55>, <74>, <73>, <72>, <16>, <28>, <40>, <58>, <5>, <17>, <29>, <41>,
<59>, <75>, <6>, <18>, <30>, <42>, <60>, <76>, <7>, <19>, <31>, <43>, <61>, <77>,
<8>, <20>, <32>, <44>, <62>, <78>, <9>, <21>, <33>, <45>, <63>, <79>;

The misalignment is triggering me 😂

Comment thread app/boards/arm/glove80/glove80_lh.dts Outdated
Comment on lines +25 to +27
pixel-lookup = <52>, <53>, <54>, <69>, <70>, <71>, <15>, <27>, <39>, <51>, <4>, <14>, <26>, <38>,
<50>, <68>, <3>, <13>, <25>, <37>, <49>, <67>, <2>, <12>, <24>, <36>, <48>, <66>,
<1>, <11>, <23>, <35>, <47>, <65>, <0>, <10>, <22>, <34>, <46>, <64>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pixel-lookup = <52>, <53>, <54>, <69>, <70>, <71>, <15>, <27>, <39>, <51>, <4>, <14>, <26>, <38>,
<50>, <68>, <3>, <13>, <25>, <37>, <49>, <67>, <2>, <12>, <24>, <36>, <48>, <66>,
<1>, <11>, <23>, <35>, <47>, <65>, <0>, <10>, <22>, <34>, <46>, <64>;
pixel-lookup = <52>, <53>, <54>, <69>, <70>, <71>, <15>, <27>, <39>, <51>, <4>, <14>, <26>, <38>,
<50>, <68>, <3>, <13>, <25>, <37>, <49>, <67>, <2>, <12>, <24>, <36>, <48>, <66>,
<1>, <11>, <23>, <35>, <47>, <65>, <0>, <10>, <22>, <34>, <46>, <64>;

#define PINK 0xffc0cb
#define WHITE 0xffffff
#define ___ 0x000000
#define BLACK 0x000000 No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define BLACK 0x000000
#define BLACK 0x000000

Add missing newline


void set_peripheral_layers_state(uint32_t new_layers);
bool peripheral_layer_active(uint8_t layer);
uint8_t peripheral_highest_layer_active(void);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint8_t peripheral_highest_layer_active(void);
uint8_t peripheral_highest_layer_active(void);

missing newline

Comment thread app/include/zmk/rgb_underglow_layer.h Outdated
const struct zmk_behavior_binding *rgb_underglow_get_bindings(uint8_t layer);

uint8_t rgb_underglow_top_layer_with_state(uint32_t state_to_test);
uint8_t rgb_underglow_top_layer(void); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint8_t rgb_underglow_top_layer(void);
uint8_t rgb_underglow_top_layer(void);

missing newline

#include <zephyr/kernel.h>
#include <zmk/events/underglow_color_changed.h>

ZMK_EVENT_IMPL(zmk_underglow_color_changed); No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ZMK_EVENT_IMPL(zmk_underglow_color_changed);
ZMK_EVENT_IMPL(zmk_underglow_color_changed);

missing newline

Comment thread app/src/split/peripheral_layers.c Outdated
}
}
return 0;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}

missing newline

Comment thread app/src/rgb_underglow_layer.c Outdated
return peripheral_highest_layer_active();
#endif
}
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ No newline at end of file

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */

missing newline

@a-b

a-b commented Dec 13, 2025

Copy link
Copy Markdown

Curious what holds this PR from getting merged?

@darknao darknao changed the title Per key/layer RGB underglow for 25.08 Per key/layer RGB underglow for 25.11 Jan 16, 2026
@mgabor3141

Copy link
Copy Markdown

Go60 RH thumb pixel-lookup appears reversed.

The first three entries in go60_rh.dts are <57>, <58>, <59> (T3, T2, T1), but the LH equivalent in go60_lh.dts uses <54>, <55>, <56> (T1, T2, T3). The physical LED strip seems to run in the same direction on both halves, so the RH mapping ends up with T1 and T3 swapped.

In practice, setting a color at keymap position 59 (RH T1) lights up the physical T3 key, and vice versa. The main grid keys are fine, only the three thumb keys are affected.

I'd expect the fix is changing the RH pixel-lookup to <59>, <58>, <57>.

darknao added 2 commits March 24, 2026 13:29
Use &trans behavior to use color from the next visible rgb layer in the
stack.
@darknao

darknao commented Mar 24, 2026

Copy link
Copy Markdown
Author

Go60 RH thumb pixel-lookup appears reversed.

The first three entries in go60_rh.dts are <57>, <58>, <59> (T3, T2, T1), but the LH equivalent in go60_lh.dts uses <54>, <55>, <56> (T1, T2, T3). The physical LED strip seems to run in the same direction on both halves, so the RH mapping ends up with T1 and T3 swapped.

In practice, setting a color at keymap position 59 (RH T1) lights up the physical T3 key, and vice versa. The main grid keys are fine, only the three thumb keys are affected.

I'd expect the fix is changing the RH pixel-lookup to <59>, <58>, <57>.

That's correct.
I fixed it a few months ago, but was never pushed to this PR (I was waiting for confirmation from other users, just in case that was an isolated hardware issue on my go60, so thanks for confirming :) )
It's long overdue now, so I'll update this PR as soon as possible with that fix.

@mgabor3141

Copy link
Copy Markdown

@darknao I opened a PR to this PR's branch with the fix, feel free to merge it :)

@darknao

darknao commented Mar 29, 2026

Copy link
Copy Markdown
Author

@darknao I opened a PR to this PR's branch with the fix, feel free to merge it :)

Thanks, but the fix is already included in this branch

@leika

leika commented Jun 13, 2026

Copy link
Copy Markdown

I love the work here and I'm no stranger to run my own zmk forks and experiments, but i still wonder why this ist still a PR. Seems stable to me and a basic functionality, is the moergo fork of zmk moving that slow really ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.